﻿--提取职级异动一级审批列表数量
Create proc [dbo].[proc_Employee_GradeMove_GetApplyFList_Count]
(
	@ename nvarchar(50),
	@companyid int,
	@audit nvarchar(4)
)
as
Begin
	Select Count(E.Id) from employee_Grade EE inner join Employee E on EE.EId=E.Id
			where
				 e.ename like '%'+@ename+'%'
			 and (@CompanyId=0 Or E.Companyid = @CompanyId)
			 and ee.Proposer is not null
			 and (case when ee.firstaudit=1 then '1' 
				   when ee.firstaudit=0 and ee.firstauditperson is null then '0'
				   when ee.firstaudit=0 and ee.firstauditperson is not null then '1' end) like '%'+@audit+'%'
			and  e.state <> 5 
End
	RETURN
